import Network from './network'

export const login = (data) => Network.post('/login', data)
export const getAll = () => Network.get('/allstudents')
export const register = (data) => Network.post('/register', data)

/* 学生相关 */
export const getClassInfo = (sid) => Network.get(`/classInfo?sid=${sid}`)
export const joinCourseByCode = (sid, code) => Network.post(`/joinCourse?sid=${sid}&code=${code}`)
export const getClassAndAssignment = (sid) => Network.get(`/assignmentList?sid=${sid}`)
export const dropClass = (sid, cid) => Network.post(`/dropclass?sid=${sid}&cid=${cid}`)
export const getCourseById = (cid) => Network.get(`/getCourse?cid=${cid}`)
export const getCourseCount = (cid) => Network.get(`/getcourseCount?cid=${cid}`)
export const getAssignment = (cid, sid) => Network.get(`/getAssignment?cid=${cid}&sid=${sid}`)
export const getStuWork = (aid, sid) => Network.get(`/getStuWork?aid=${aid}&sid=${sid}`)
export const getStuInfo = (sid) => Network.get(`/getStuInfo?sid=${sid}`)
export const editStudent = (data) => Network.post('/editStudent', data)

// /*老师相关*/
/* 创建课程 */
export const createCourseByTid = (data) => Network.post('/createCourse', data)
/* 查询老师课程 */
export const getTeacherClassInfo = (tid) => Network.get(`/getClassInfoByTid?tid=${tid}`)
/* 删除老师课程 */
export const deleteCourse = (tid, cid) => Network.delete(`/deleteCourseByCid?tid=${tid}&cid=${cid}`)

/**/
export const getAssignmentLinkCourse = (cid, sid) => Network.get(`/getAssignmentLinkCourse?cid=${cid}&sid=${sid}`)
export const getTeacherInfo = (tid) => Network.get(`/getTeacherByTid?tid=${tid}`)
export const editTeacher = (data) => Network.post('/editTeacher', data)
export const editCourseInfo = (data) => Network.post('/editCourseInfo', data)

export const createAssignment = (data) => Network.post('/createAssignment', data)
export const selectAssignmentDetail = (aid) => Network.get(`/getAssignmentDeatil?aid=${aid}`)
export const getAssignmentByAid = (aid) => Network.get(`/getAssignmentByAid?aid=${aid}`)

/* 修改分数 */
export const editScore = (sid, aid, score, ischeck) => Network.post(`/editScore?sid=${sid}&aid=${aid}&score=${score}&ischeck=${ischeck}`)

/* 删除作业 */
export const deleteAssignmentByAid = (aid) => Network.delete(`/deleteAssignmentByAid?aid=${aid}`)

/* 修改作业 */
export const editAssignment = (data) => Network.post('/editAssignment', data)

/* 老师作业置顶 */
export const updateTop = (cid) => Network.get(`/updateTop?cid=${cid}`)

/* 老师作业取消置顶 */
export const updateNoTop = (cid) => Network.get(`/updateNoTop?cid=${cid}`)

/* 老师查询置顶课程 */
export const getCourseTop = () => Network.get('/getCourseTop')

/* 学生作业置顶 */
export const updateStudentTop = (cid, sid) => Network.get(`/updateStudentTop?cid=${cid}&sid=${sid}`)

/* 学生作业取消置顶 */
export const updateStudentNoTop = (cid, sid) => Network.get(`/updateStudentNoTop?cid=${cid}&sid=${sid}`)

/* 学生查询置顶课程 */
export const getStudentCourseTop = (sid) => Network.get(`/getStudentCourseTop?sid=${sid}`)

/* 学生查询其他课程 */
export const getStudentOtherCourseTop = (sid) => Network.get(`/getStudentOtherCourseTop?sid=${sid}`)
